<?php

/**
 * shipping actions.
 *
 * @package    sf_sandbox
 * @subpackage shipping
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 2288 2006-10-02 15:22:13Z fabien $
 */
class shippingActions extends autoshippingActions
{
    protected function getShippingOrCreate($id = 'id')
    {
        $sh = parent::getShippingOrCreate($id);
        $sh->setCulture($this->getUser()->getCulture());
        $sh->setStatusId( $sh->getStatusId() ? $sh->getStatusId() : MyConstants::STATUS_APPROVED );

        return $sh;
    }
    protected function saveShipping($shipping)
    {
        /* @var $shipping Shipping */
    	if( $this->getRequestParameter('in_same_country') == 1 )
    		$shipping->setInSameCiuntry(MyConstants::STATUS_APPROVED);
    	else 
    		$shipping->setInSameCiuntry(MyConstants::STATUS_DELETED);
        $shipping->setPrice(str_replace(array(',', '.'), '', $this->getRequestParameter('shipping[price]')));
        $shipping->setCurrency($this->getRequestParameter('shipping[currency]'));
        $shipping->save();
    }
}
